﻿using MediatR;
using RBAC.LuFang.API.Application.Command.MenuCommand;
using RBAC.LuFang.Domain;
using RBAC.LuFang.Domin.Services;

namespace RBAC.LuFang.API.Application.CommandHandlers.MenuHandler
{
    //菜单添加
    public class MenuCreateCommandHangler:IRequestHandler<MenuCreateCommand,int>
    {
        private readonly IMenuService _menuService;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="menuService"></param>
        public MenuCreateCommandHangler(IMenuService menuService)
        {
            _menuService = menuService;
        }

        public async Task<int> Handle(MenuCreateCommand request, CancellationToken cancellationToken)
        {
            var menuModel=new MenuInfo() {menuInfoName=request.menuInfoName,menuInfoUrl=request.menuInfoUrl,Pid=request.Pid};
            return await _menuService.AddMenu(menuModel);
        }
    }
}
